#ifndef CVX_DXUT_FRAME_H
#define CVX_DXUT_FRAME_H 1

//dxut framework: mouse, keyboard etc

#include "cvxDxut.h"
#include "cvxD3d9.h"
#include "nv_stereo_utils.h"
#include "cvxSurface.h"
#include "d3dStereoCamera.h"
#include "d3dGauge.h"
#include "stdGauge.h"
#include "ImageModel.h"
#include <conio.h>
#include "UserInputUI.h"
#include "FileIO.h"
#include "cvxReferenceFrame.h"


class DxutStereoFrame
{
public:
	static CDXUTDialogResourceManager  s_dialogResourceManager;
	static CDXUTDialog                 s_hud;                  // dialog for standard controls
	static CDXUTDialog                 s_sampleUI;
	static CDXUTTextHelper*            s_pTxtHelper;

	static ID3DXFont*                  s_pFont9;	
	static ID3DXSprite*                s_pSprite9;

	static CvxStereoSurface *          s_pStereoSurface;
	
	static bool                        s_isFullScreen;
	static bool						   s_isFinishTesting;
	static bool                        s_isShowGroudTruth;
	static UsertInputUI     *          s_userInput;
	static FileIO           *          s_fileIO;
	static int                         s_lastMousePosX;
	static int                         s_lastMousePosY;

	//two button
	static D3dStereoCamera*            s_pStereoCam;
	static StdGauge       *            s_pstdGauge;           //gauge controled by users
	static StdGauge       *            s_groundTruthGauge;   
	static ImageModel  *               s_imageModel;   //provides ground truth and save result
	static SampleItem  *               s_pSampleItem;  //used input orientation
	static CvxReferenceFrame *         s_pEstimatedItem;   //already setted positions

public:
	static void InitApp();
	static void RenderText();
	static void RenderImageCount(int num, int totalNum);
	static void RenderExpConfiguration(bool isStereo, bool isSquare, bool isCaustic, char pOrv);
	static void RenderThanks();
	static void RenderSeperation();
	static void RenderAngleDifferenceReminder();


	static int Width();
	static int Height();
	static bool OpenNewFile();
	static bool OpenSaveFile();
	static bool OpenNewFileWithMultipleTestCases();

	static LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing,
									 void* pUserContext );

	static void CALLBACK OnKeyboard( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );
	static void CALLBACK OnMouse( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, 
								  bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext );	
	static void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );




	static void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext );


	static  bool CALLBACK IsD3D9DeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat,
											      D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext );

	static HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
										void* pUserContext );
	static HRESULT CALLBACK OnD3D9ResetDevice( IDirect3DDevice9* pd3dDevice,
								const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );


	static void CALLBACK OnD3D9DestroyDevice( void* pUserContext);

	static void CALLBACK OnD3D9LostDevice( void* pUserContext );

	static void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );


private:
	// test files sequence
	static bool LoadConfigFile(const string &fileName);



};


#endif